import 'package:demo_app_video/commons/sp.dart';
import 'package:demo_app_video/dialog/password_dialog.dart';
import 'package:demo_app_video/store/user.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class AdolescentPage extends StatefulWidget {
  const AdolescentPage({Key? key}) : super(key: key);

  @override
  State<AdolescentPage> createState() => _AdolescentPageState();
}

class _AdolescentPageState extends State<AdolescentPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Color(0xffFFFFFF),
        centerTitle: true,
        title: Text(
          '青少年模式',
          style: TextStyle(fontSize: 16.sp),
        ),
      ),
      body: Observer(
          builder: (_) => Container(
                width: double.infinity,
                height: double.infinity,
                child: SingleChildScrollView(
                  padding: EdgeInsets.only(left: 20.w, right: 20.w),
                  child: Column(
                    children: [
                      Container(
                        width: 80.w,
                        height: 80.w,
                        margin: EdgeInsets.only(top: 20.h, bottom: 10.h),
                        child: Image.asset(
                          'images/xiaosan.png',
                          fit: BoxFit.fill,
                        ),
                      ),
                      Container(
                        height: 20.h,
                      ),
                      Text(
                        '${$UserStore.qing == '1' ? '青少年模式已开启' : '青少年模式已关闭'}',
                        style: TextStyle(
                            color: Color(0xff333333),
                            fontSize: 16.sp,
                            fontWeight: FontWeight.bold),
                      ),
                      Container(
                        height: 20.h,
                      ),
                      Container(
                        alignment: Alignment.centerLeft,
                        child: Text(
                          '青少年模式介绍:',
                          style: TextStyle(
                              fontSize: 12.sp, fontWeight: FontWeight.bold),
                          textAlign: TextAlign.left,
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.only(top: 5.h, bottom: 10.h),
                        child: Text(
                          '开启青少年模式后,将自动为您开启时间锁,时间锁默认1小时,单日使用时长超过触发事件,需要由监护人输入密码,才能继续使用',
                          style: TextStyle(
                              color: Color(0xff999999), fontSize: 12.sp),
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.only(top: 5.h),
                        alignment: Alignment.centerLeft,
                        child: Text(
                          '使用方法:',
                          style: TextStyle(
                              fontSize: 12.sp, fontWeight: FontWeight.bold),
                          textAlign: TextAlign.left,
                        ),
                      ),
                      Container(
                        child: Text(
                          '开启青少年模式,需要先设置独立四位密码,请牢记您的密码,关闭此模式时需要输入密码,如果忘记密码,可选择申诉重置',
                          style: TextStyle(
                              color: Color(0xff999999), fontSize: 12.sp),
                        ),
                      ),
                      Container(
                        height: 40.h,
                      ),
                      GestureDetector(
                        onTap: () => click_qing_data(),
                        child: Container(
                          width: 328.w,
                          height: 50.h,
                          decoration: BoxDecoration(
                              color: Color(0xffFF0000),
                              borderRadius: BorderRadius.circular(12.sp)),
                          alignment: Alignment.center,
                          child: Text(
                            '${$UserStore.qing == '1' ? '关闭青少年模式' : '开启青少年模式'}',
                            style: TextStyle(
                                color: Color(0xffFFFFFF), fontSize: 16.sp),
                          ),
                        ),
                      )
                    ],
                  ),
                ),
              )),
      backgroundColor: Color(0xffFFFFFF),
    );
  }

  click_qing_data() async {
    //秘密弹窗

    var resultData = await showModalBottomSheet<dynamic>(
      backgroundColor: Colors.transparent,
      isScrollControlled: true,
      context: context,
      builder: (BuildContext context) {
        return StatefulBuilder(builder: (context1, state) {
          return PasswordDialog();
        });
      },
    );
  }
}
